<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加客户</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/css/oksub.css">
    <script type="text/javascript" src="/static/lib/loading/okLoading.js"></script>
    <script src="/static/lib/layui/layui.js"></script>
</head>
<body>
<div class="ok-body">
    <!--form表单-->
    <form class="layui-form layui-form-pane ok-form">
        <div class="layui-form-item">
            <div class="layui-inline layui-col-md5">
                <label class="layui-form-label">机构代码<span style="color: red">*</span></label>
                <div class="layui-input-inline">
                    <input style="width: 215%;" type="text" name="cus_code" placeholder="组织机构代码(唯一)" lay-verify="required|phone" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline layui-col-md5" style="padding-left: 50px;">
                <label class="layui-form-label">客户名称<span style="color: red">*</span></label>
                <div class="layui-input-inline">
                    <input style="width: 225%;" type="text" name="cus_name" lay-verify="email" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
         <div class="layui-form-item">
            <div class="layui-inline layui-col-md5">
                <label class="layui-form-label">业务联系人<span style="color: red">*</span></label>
                <div class="layui-input-inline">
                    <input style="width: 215%;" type="text" name="cus_key_person" lay-verify="required|phone" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline layui-col-md5" style="padding-left: 50px;">
                <label class="layui-form-label">联系电话<span style="color: red">*</span></label>
                <div class="layui-input-inline">
                    <input style="width: 225%;" type="tel" name="cus_key_person_phone" lay-verify="email" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline layui-col-md5">
                <label class="layui-form-label">开户行账号<span style="color: red">*</span></label>
                <div class="layui-input-inline">
                    <input style="width: 215%;" type="text" name="cus_bank_code" lay-verify="required|phone" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline layui-col-md5" style="padding-left: 50px;">
                <label class="layui-form-label">开户行名称<span style="color: red">*</span></label>
                <div class="layui-input-inline">
                    <input style="width: 225%;" type="text" name="cus_bank_address" lay-verify="email" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline layui-col-md5">
                <label class="layui-form-label">经济性质<span style="color: red">*</span></label>
                <div class="layui-input-inline">
                    <input style="width: 215%;" type="tel" name="cus_economic" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline layui-col-md5" style="padding-left: 50px;">
                <label class="layui-form-label">所属行业<span style="color: red">*</span></label>
                <div class="layui-input-inline">
                    <input style="width: 225%;" type="text" name="cus_industry" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline layui-col-md5">
                <label class="layui-form-label">注册资本<span style="color: red">*</span></label>
                <div class="layui-input-inline">
                    <input style="width: 215%;" type="text" name="cus_registered_capital" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline layui-col-md5" style="padding-left: 50px;">
                <label class="layui-form-label">成立时间<span style="color: red">*</span></label>
                <div class="layui-input-inline">
                    <input style="width: 225%;" type="text" name="cus_registered_time" id="cus_registered_time" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item" id="area-picker">
            <div class="layui-inline layui-col-md8">
                <label class="layui-form-label">所在地域<span style="color: red">*</span></label>
                <div class="layui-input-inline" style="width: 25%; margin-left: 10px">
                    <select name="province" id="province" class="province-selector" data-value="" lay-filter="province-1">
                        <option value="">请选择省</option>
                    </select>
                </div>

                <div class="layui-input-inline" style="width: 25%; margin-left: 0;">
                    <select name="city" id="city" class="city-selector" data-value="" lay-filter="city-1">
                        <option value="">请选择市</option>
                    </select>
                </div>

                <div class="layui-input-inline" style="width: 25%; margin-left: 0;">
                    <select name="county" id="county" class="county-selector" data-value="" lay-filter="county-1">
                        <option value="">请选择区</option>
                    </select>
                </div>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-inline layui-col-md5">
                <label class="layui-form-label">详细地址<span style="color: red">*</span></label>
                <div class="layui-input-inline">
                    <input style="width: 215%;" type="text" name="cus_address" id="cus_address" lay-verify="required" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline layui-col-md5" style="padding-left: 50px;">
                <label class="layui-form-label">状态<span style="color: red">*</span></label>
                <div class="layui-input-block">
                    <input style="width: 225%;" type="checkbox" id="now_status" name="now_status" lay-skin="switch" lay-text="启用|停用"
                           checked="checked">
                </div>
            </div>
        </div>







        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">经营范围<span style="color: red">*</span></label>
            <div class="layui-input-block">
                <textarea name="remark_describe" placeholder="请输入备注内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remark_describe" placeholder="请输入备注内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="add">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<!--js逻辑-->
<script>
    layui.use(["form", "okUtils", "form", "layarea", "laydate", "okLayer"], function () {
        let $ = layui.$;
        let form = layui.form;
        let okUtils = layui.okUtils;
        let okLayer = layui.okLayer;
        let tree = layui.tree;
        let laydate = layui.laydate;
        let layarea = layui.layarea;
        okLoading.close();
        layarea.render({
            elem:"#area-picker",
            data:{
                province: '浙江省',
                city: '杭州市',
                county: '西湖区',
            }
        });
        laydate.render({elem: "#cus_registered_time", type: "date", trigger:"click"});
        // 这里得把switch的状态弄对，不然，如果他创建就停用，数据就传不过去了
        form.on("submit(add)",function (data) {
            if(data.field.now_status=="on"){
                data.field.now_status=0;
            }else{
                data.field.now_status=1;
            }
            okUtils.ajax("/customer/economic/","post",data.field, true).done(function (response) {
                okLayer.greenTickMsg(response.msg, function () {
					parent.layer.close(parent.layer.getFrameIndex(window.name));
				});
            }).fail(function (error) {
                // 这里已经有提示了
            });
            return false;
        });
    });
</script>
</body>
</html>
